import {input} from "./comiee.mjs";
import {Client, AsyncClient} from "./client.mjs"

AsyncClient.with('debug', async client => {
    for (let i = 0; i < 3; i++) {
        console.log(await client.send(i.toString()));
    }
})

const client = new Client('js');

client.subscribe('debug', text => {
    console.log('调测信息：', text);
    return text;
});

+async function () {
    client.startListen();
    await client.register();
    while (true) {
        let s = await input();
        if (s === '') break;
        console.log(await client.send('debug', s));
    }
    client.close(); // TODO 不知道为什么，close之后程序没有结束
}()